package common

const (
	GIN_CTX_CONFIG_LOGGER = "gin_logger"

	JWT_SA_HEADER = "x-serviceAccount"

	GIN_CTX_CONFIG_CONFIG        = "gin_config"
	GIN_CTX_CONFIG_ALERTRECEIVEQ = "alertReceiveQ"
	LabelNodeRolePrefix          = "node-role.kubernetes.io/"
	NodeLabelRole                = "kubernetes.io/role"

	GIN_CTX_MONITOR_CACHE = "monitor_cache"
	GIN_CTX_STREE_CACHE   = "stree_cache"
	GIN_CTX_K8s_CACHE     = "k8s_cache"
	GIN_CTX_CICD_GITLAB   = "cicd_gitlab"
	GIN_CTX_JWT_CLAIM     = "jwt_claim"
	GIN_CTX_JWT_USER_NAME = "jwt_user_name"
	COMMON_STATUS_ENABLE  = "1"
	COMMON_STATUS_DISABLE = "0"
	RESOURCE_TYPE_ECS     = "ecs"
	RESOURCE_TYPE_ELB     = "elb"
	RESOURCE_TYPE_RDS     = "rds"

	AGENT_VAR_ENV = "VAR_ENV"
	AGENT_VERSION = "1.0"

	ERR_ECS_NOT_FOUND = "ResourceEcs不存在"

	// 任务本地的状态
	AGENT_TASK_STATUS_RUNNING = "running"
	AGENT_TASK_STATUS_KILLED  = "killed"
	AGENT_TASK_STATUS_SUCCESS = "success"
	AGENT_TASK_STATUS_FAILED  = "failed"

	// 任务的执行动作
	AGENT_TASK_ACTION_START  = "start"
	AGENT_TASK_ACTION_KILL   = "kill"
	AGENT_TASK_ACTION_PAUSE  = "pause"
	AGENT_TASK_ACTION_RESUME = "resume"
	AGENT_TASK_ACTION_STOP   = "stop"

	AGENT_TASK_SCRIPT_TYPE_SHELL  = "shell"
	AGENT_TASK_SCRIPT_TYPE_PYTHON = "python"

	// job的状态
	JOB_STATUS_PENING   = "pending"
	JOB_STATUS_RUNNING  = "running"
	JOB_STATUS_PAUSED   = "paused"
	JOB_STATUS_KILLED   = "killed"
	JOB_STATUS_KILLING  = "killing"
	JOB_STATUS_FINISHED = "finished"

	// job 的执行错误策略
	// 遇到1个机器的状态出错，那么暂停整个任务：100机器的任务：发现有节点报错了：暂停下来，去检查，避免影响扩大
	// 直接set job status=paused
	JOB_ONERROR_STRATEGY_PAUSE = "pause"
	// 不管错误，执行完就行 ：啥都不做
	JOB_ONERROR_STRATEGY_IGNORE = "ignore"
	// 终止任务
	//  直接set job status=paused
	JOB_ONERROR_STRATEGY_STOP = "stop"

	// 监控采集器 服务发现类型
	MONITOR_SCRAPE_JOB_SD_TYPE_K8S  = "kubernetes"
	MONITOR_SCRAPE_JOB_SD_TYPE_HTTP = "stree_http"

	//
	MONITOR_ALERT_MATCH_KEY     = "alert_send_group"
	MONITOR_ALERT_RULE_KEY      = "alert_rule_id"
	MONITOR_ALERT_NAME_KEY      = "alertname"
	MONITOR_ALERT_SEVERITY_KEY  = "severity"
	MONITOR_ALERT_BIND_NODE_KEY = "bind_stree_node"

	GORM_ENBALE_RES_YES = 1
	GORM_ENBALE_RES_NO  = 2

	MONITOR_ALERT_SEVERITY_CRITICAL = "critical"
	MONITOR_ALERT_SEVERITY_WARNING  = "warning"
	MONITOR_ALERT_SEVERITY_INFO     = "info"
	MONITOR_RULE_ANNO_VALUE         = "description_value"

	// 告警中 已升级 已屏蔽 已恢复
	MONITOR_ALERT_STATUS_FIRING   = "firing"
	MONITOR_ALERT_STATUS_UPGRADED = "upgraded"
	MONITOR_ALERT_STATUS_RENLING  = "renlinged"
	MONITOR_ALERT_STATUS_SILENCED = "silenced"
	MONITOR_ALERT_STATUS_RESOLVED = "resolved"
	RUN_ENV_TYPE_PROD             = "prod"
	RUN_ENV_TYPE_STAGE            = "stage"
	RUN_ENV_TYPE_DEV              = "dev"
	RUN_ENV_TYPE_PRESS            = "press"

	// k8s 任务的状态

	K8S_YAMLTASK_STATUS_PENDING = "pending"
	K8S_YAMLTASK_STATUS_APPLIED = "applied"

	K8S_NS_ALL_KEY = "bigdevops-ns-all"

	WEBSOCKET_HEARTBEAT_RESP_MSG = "WS_HEARTBEAT_RESP_PONG"

	K8S_VOLUME_TYPE_HOSTPATH  = "hostPath"
	K8S_VOLUME_TYPE_PVC       = "persistentVolumeClaim"
	K8S_VOLUME_TYPE_CONFIGMAP = "configMap"

	K8S_APP_LABEL_STREE_NAME   = "infra_stree_node"
	K8S_APP_LABEL_APP_NAME     = "infra_app_name"
	K8S_APP_LABEL_PROJECT_NAME = "infra_project_name"
	K8S_APP_LABEL_INS_NAME     = "infra_instance_name"
	K8S_APP_LABEL_CRONJOB_NAME = "infra_cronjob_name"
	K8S_APP_LABEL_VERSION      = "app_version"

	// 等待部署
	//     -  部署成功 --> 等待测试
	//                    - 测试成功
	//                    - 测试失败
	//     -  部署失败 --> 结束了
	// 总结结束的状态有3个： 部署失败  测试成功 测试失败
	// 为什么要强调这个stage的结束 --> 跳到下一个stage
	// 等待部署--> 等待测试 或部署失败
	// 等待测试==测试成功
	CICD_STAGE_DEPLOY_PENDING         = "deploy_pending"
	CICD_STAGE_DEPLOY_SUCCESS         = "test_pending"
	CICD_STAGE_ROLLBACK_SUCCESS       = "rollbacked"
	CICD_STAGE_TEST_SUCCESS           = "test_success"
	CICD_STAGE_TEST_FAILED            = "test_failed"
	CICD_STAGE_DEPLOY_FAILED          = "deploy_failed"
	CICD_STAGE_DEPLOY_SUCCESS_CHINESE = "部署成功"
	CICD_STAGE_DEPLOY_FAILED_CHINESE  = "部署失败"

	CICD_ORDER_STAGE_FRONT_CLASS = "class-title-r"

	CICD_DEPLOY_NAME_BY_ORDER = "cicd-order"
	CICD_ROLLOUT_NAME_PREFIX  = "rollout"
)

var (
	MONITOR_ALERT_STATUS_ARRAY = []string{
		MONITOR_ALERT_STATUS_FIRING,
		MONITOR_ALERT_STATUS_UPGRADED,
		MONITOR_ALERT_STATUS_SILENCED,
		MONITOR_ALERT_STATUS_RESOLVED,
	}
	RUN_ENV_TYPE_ARRAY = []string{
		RUN_ENV_TYPE_PROD,
		RUN_ENV_TYPE_STAGE,
		RUN_ENV_TYPE_DEV,
		RUN_ENV_TYPE_PRESS,
	}
	COMMON_SHOW_MAP = map[string]bool{
		"1": true,
		"0": false,
	}
	MONITOR_ALERT_SEVERITY_TITLE_COLOR_MAP = map[string]string{
		MONITOR_ALERT_SEVERITY_CRITICAL: "red",
		MONITOR_ALERT_SEVERITY_WARNING:  "yellow",
		MONITOR_ALERT_SEVERITY_INFO:     "blue",
	}

	MONITOR_ALERT_STATUS_CH_MAP = map[string]string{
		MONITOR_ALERT_STATUS_FIRING:   "触发中",
		MONITOR_ALERT_STATUS_RESOLVED: "已恢复",
	}

	MONITOR_ALERT_STATUS_COLOR_MAP = map[string]string{
		MONITOR_ALERT_STATUS_FIRING:   "red",
		MONITOR_ALERT_STATUS_RESOLVED: "green",
	}

	JOB_ACTION_NEXT_STATUS_MAP = map[string]string{

		AGENT_TASK_ACTION_START:  JOB_STATUS_RUNNING,
		AGENT_TASK_ACTION_KILL:   JOB_STATUS_KILLING,
		AGENT_TASK_ACTION_PAUSE:  JOB_STATUS_PAUSED,
		AGENT_TASK_ACTION_RESUME: JOB_STATUS_RUNNING,
		AGENT_TASK_ACTION_STOP:   JOB_STATUS_FINISHED,
	}

	JOB_ACTION_TRAN_MAP = map[string]string{
		AGENT_TASK_ACTION_START:  "开始",
		AGENT_TASK_ACTION_KILL:   "紧急杀死",
		AGENT_TASK_ACTION_PAUSE:  "暂停",
		AGENT_TASK_ACTION_RESUME: "恢复",
		AGENT_TASK_ACTION_STOP:   "停止",
	}
	//	  {
	//    value: 'Approval',
	//    label: '审批节点',
	//  },
	//  {
	//    value: 'Action',
	//    label: '执行节点',
	//  },
	//  {
	//    value: 'Stop',
	//    label: '结束节点',
	//  }
	FLOW_TYPE_Approval = "Approval"
	FLOW_TYPE_Action   = "Action"

	FLOW_TYPE_MAP = map[string]string{
		FLOW_TYPE_Approval: "审批节点",
		FLOW_TYPE_Action:   "执行节点",
		"Stop":             "结束节点",
	}

	BOOL_COLLOR_MAP = map[bool]string{
		true:  "green",
		false: "red",
	}

	WorkOrderInstanceStatus_MAP = map[string]string{
		WorkOrderInstanceStatusPendingApproval: "待审批的",
		WorkOrderInstanceStatusApprovalReject:  "审批拒绝的",
		WorkOrderInstanceStatusApprovalReject1: "审批拒绝",
		WorkOrderInstanceStatusApprovalPass:    "审批通过",
		WorkOrderInstanceStatusPendingAction:   "待执行的",
		WorkOrderInstanceStatusUnderAction:     "执行中",
		WorkOrderInstanceStatusFinished:        "已执行完成的",
	}

	CicdStageStatusChineseMap = map[string]string{
		CICD_STAGE_DEPLOY_PENDING:   "等待部署",
		CICD_STAGE_DEPLOY_SUCCESS:   "部署成功，等待测试",
		CICD_STAGE_ROLLBACK_SUCCESS: "已回滚",
		CICD_STAGE_TEST_SUCCESS:     "测试成功",
		CICD_STAGE_TEST_FAILED:      "测试失败",
		CICD_STAGE_DEPLOY_FAILED:    "部署失败",
	}

	ApprovalActionPass   = "pass"
	ApprovalActionReject = "reject"
	ApprovalActionMap    = map[string]string{
		ApprovalActionPass:   "",
		ApprovalActionReject: "",
	}
	ResultSuccess = "success"
	ResultFailed  = "failed"
	ResultMap     = map[string]string{
		CICD_STAGE_TEST_SUCCESS: "",
		CICD_STAGE_TEST_FAILED:  "",
	}
	ResultMapChinese = map[string]string{
		CICD_STAGE_TEST_SUCCESS: "测试成功",
		CICD_STAGE_TEST_FAILED:  "测试失败",
	}

	WorkOrderInstanceQueryModeCreate   = "mine"
	WorkOrderInstanceQueryModeAll      = "all"
	WorkOrderInstanceQueryModeApproval = FLOW_TYPE_Approval
	WorkOrderInstanceQueryModeAction   = FLOW_TYPE_Action

	WorkOrderInstanceStatusPendingApproval = "pendingApproval"
	WorkOrderInstanceStatusApprovalReject  = "approvalReject"
	WorkOrderInstanceStatusApprovalReject1 = "reject"
	WorkOrderInstanceStatusApprovalPass    = "pass"
	WorkOrderInstanceStatusPendingAction   = "pendingAction"
	WorkOrderInstanceStatusUnderAction     = "underAction"
	WorkOrderInstanceStatusFinished        = "finished"
)
